package czy.demo.controller;

import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/* 计算操作 */
/*
 * Api注解，每个tag会被作为一个组显示
 * base url没有作用
 */
@Api(value = "operation",tags = {"operation"},description = "四则运算",position = 0)
@RestController
@RequestMapping("/operation")
public class OperationController {

    /* response也不起作用，压根没有这项,produces有作用,consumes也没啥用 */
    @ApiOperation(value = "加法运算",consumes = "text/plain",produces = "application/text",response = double.class)
    @ApiImplicitParams({
            /* allowableValues会导致一个可选值列表，dataTypeClass不起作用，类型一直都是string */
            @ApiImplicitParam(name="one",value = "第一个加数",required = true,dataTypeClass = Double.class),
            @ApiImplicitParam(name="two",value = "第二个加数",required = true,dataTypeClass = Double.class)
    })
    @GetMapping("/add")
    public double add(@ApiParam double one, double two){
        return one+two;
    }


}
